package com.yueyin.ui.main;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class MyBroadcastReceiver extends BroadcastReceiver {

    public static boolean pass = false;

    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if ("android.intent.action.HEADSET_PLUG".equals(action)) {

            if (intent.getIntExtra("state", 0) == 1) {
                Toast.makeText(context, "耳机已连接!", Toast.LENGTH_SHORT).show();
                pass = true;
            } else {

                Toast.makeText(context, "耳机已断开!", Toast.LENGTH_SHORT).show();
                pass = false;
            }
        }
    }


}
